package com.chencs.app.product.controller;
import com.alibaba.fastjson.JSON;
import com.chencs.app.product.service.AppProductService;
import com.chencs.vo.net.request.*;
import framework.model.ResponseOptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/10/10.
 */

@RestController
@RequestMapping("/app/product")
public class AppProductController {

    @Autowired
    private AppProductService appProductService;


    /**getProduct
     * 获取商品詳情
     * @return
     */
    @RequestMapping(value = "/findProduct", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String findProduct(@RequestBody ProductRequest request){
        String retStr = "";
        try {
            retStr = appProductService.findProduct(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }

    @RequestMapping(value = "/getProductList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getProductList(@RequestBody ProductListRequest request){
        String retStr = "";
        try {
            retStr = appProductService.getProductList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }

    /**
     * 相似商品
     * @param productRequest
     * @return
     */
    @RequestMapping(value = "/getSimilarProductList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getSimilarProductList(@RequestBody ProductRequest  request){
        String retStr = "";
        try {
            retStr = appProductService.getSimilarProductList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }


    /**
     * @return
     */
    @RequestMapping(value = "/getParityProductList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getParityProductList(@RequestBody ProductRequest  request){
        String retStr = "";
        try {
            retStr = appProductService.getParityProductList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }


    //top榜单
    /**
     * @return
     */
    @RequestMapping(value = "/topList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String topList(@RequestBody PushRequest request){
        String retStr = "";
        try {
            retStr = appProductService.topList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }

    /**
     * @return
     */
    @RequestMapping(value = "/dayUpdate", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String dayUpdate(@RequestBody PushRequest  request){
        String retStr = "";
        try {
            retStr = appProductService.dayUpdate(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }



    /**
     * @return
     */
    @RequestMapping(value = "/getJHSList", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getJHSList(@RequestBody ProductRequest request){
        String retStr = "";
        try {
            retStr = appProductService.getJHSList(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }


    /**
     * @return
     */
    @RequestMapping(value = "/getjhsItem", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getjhsItem(@RequestBody RequestBase request){
        String retStr = "";
        try {
            retStr = appProductService.getjhsItem(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;

    }


    /**
     * @return
     */
    @RequestMapping(value = "/getCommand", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String getCommand(@RequestBody ProductRequest request){
        String retStr = "";
        try {
            retStr = appProductService.getCommand(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }


    /**
     * 高佣金
     * @return
     */
    @RequestMapping(value = "/applyCommission", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
    public String applyCommission(@RequestBody ApplyCommissionRequest request){
        String retStr = "";
        try {
            retStr = appProductService.applyCommission(request);
        } catch (Exception e) {
            retStr = ResponseOptUtil.commonMsgError( ResponseOptUtil.RET_FAIL_MSG);
            e.printStackTrace();
        }
        return retStr;
    }



}
